$(function(){
	$("#searchButton").click(function(){
		$("#form-industry-list").submit();
	});

	$("#delButton").click(function(){
		layer.confirm('确认要删除吗？',function(index){
			var checkBoxes = $("input:checkbox:checked");
			var deleteIds = "0";
			checkBoxes.each(function(){
				deleteIds += ","+$(this).attr("id");
			});
			$.ajax({
	        	type:"post",
	        	dataType:'json',
	        	url: contextPath+"/admin/industry/batchDelete.do",
	            data: {deleteIds:deleteIds},
	            success: function (json) {
	            	if(json.flag){
	            		if(layer.msg('已删除!',{icon:1,time:1500})){
	            			//window.location.reload();
	            			$("#form-industry-list").submit();
	            		}
	            	}
	            }
	        });

		});
	});

	$("#addButton").click(function(){
		var index = layer.open({
			type: 2,
			title: "新建行业",
			content: contextPath+"/admin/industry/toAdd.do"
		});
		layer.full(index);
	});

	$("#addSaveButton").click(function(){
		$.ajax({
        	type:"post",
        	dataType:'json',
        	url: contextPath+"/admin/industry/add.do",
            data: {name:$("#industry-name").val(),description:$("#industry-description").val(),type:$("#industry-type").val()},
            success: function (json) {
            	if(json.flag){
            		jQuery("#form-industry-list", parent.document).submit();
            	}
            }
        });
	});
});

